<h1>
    source code
</h1>
<textarea rows="55" cols="150" id="code"></textarea>

<script type="text/javascript" src="/kissy/build/seed.js"></script>
<script src="/kissy/src/package.js"></script>
<script type="text/javascript" id="script">
    var S = KISSY,
            Event = S.Event;

    (function () {

        var idle = S.mix({
        }, Event.Target);

        window.Idle = {
            idleThreshold: 1000,
            on: function (fn, context) {
                idle.on('idle', fn, context);
            },
            detach: function () {
                idle.detach('idle', fn, context);
            }
        };

        Event.on(document, 'keydown mousemove touchstart touchmove mousewheel', check);

        var idleTimer,
                idleIndex = 0;

        function check() {
            if (idleTimer) {
                clearTimeout(idleTimer);
            }
            var lastIdleTime = S.now();
            idleTimer = setTimeout(function () {
                idleTimer = null;
                idle.fire('idle', {
                    idleIndex: ++idleIndex,
                    idleTime: S.now() - lastIdleTime
                });
            }, Idle.idleThreshold);
        }
    })();

    Idle.idleThreshold = 1000;

    Idle.on(function (e) {
        S.log('idle!');
        S.log(e.idleIndex);
        S.log(e.idleTime);
    });
</script>


<script type="text/javascript">
    S.one('#code').val(S.one('#script').text());
</script>